package com.wuyan.locationdog.adapter

import android.graphics.Color
import androidx.annotation.LayoutRes
import com.arcsoft.commonbase.bean.ShareTimeBean
import com.blankj.utilcode.util.ColorUtils
import com.blankj.utilcode.util.SizeUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.wuyan.locationdog.R
import leifu.shapelibrary.ShapeView


class DogTypeListAdapter(@LayoutRes layoutResId: Int, data: MutableList<ShareTimeBean>?) :
    BaseQuickAdapter<ShareTimeBean, BaseViewHolder>(layoutResId, data) {


    override fun convert(holder: BaseViewHolder, item: ShareTimeBean) {
        holder.apply {
            holder.setText(R.id.name, item.time)
            val shapeView = holder.getView<ShapeView>(R.id.shapeView)

            if (item.time == "手动添加") {
                holder.setTextColorRes(R.id.name, com.arcsoft.commonbase.R.color.text_color_selected)
                holder.setGone(R.id.iv_select, true)

                shapeView.setShapeStrokeColor(ColorUtils.getColor(com.arcsoft.commonbase.R.color.text_color_selected))
                    .setShapeSolidColor(ColorUtils.getColor(com.arcsoft.commonbase.R.color.text_color_selected_10))
                    .setShapeSrokeDashWidth(SizeUtils.dp2px(1F).toFloat())
                    .setShapeStrokeDashGap(SizeUtils.dp2px(1F).toFloat())
                    .setUseShape()
            } else {
                if (item.isSelect) {
                    holder.setVisible(R.id.iv_select, true)
                    holder.setTextColorRes(R.id.name, com.arcsoft.commonbase.R.color.text_color_selected)

                    shapeView.setShapeStrokeColor(ColorUtils.getColor(com.arcsoft.commonbase.R.color.text_color_selected))
                        .setShapeSolidColor(ColorUtils.getColor(com.arcsoft.commonbase.R.color.text_color_selected_10))
                        .setUseShape()
                } else {
                    holder.setGone(R.id.iv_select, true)
                    holder.setTextColorRes(R.id.name, com.arcsoft.commonbase.R.color.color_3)
                    shapeView.setShapeStrokeColor(Color.parseColor("#DCDEE0"))
                        .setShapeSolidColor(Color.WHITE)
                        .setUseShape()
                }
            }
        }
    }
}


